import api, { type ResponseData } from '../index'
import type { SkinKey,TabbarPageItem,SplashOption } from '@/common/stores'

// 域名归属key
// #ifdef H5
export const getAuthorization = (data: {
	domain: string
}) => api.get<{
	code:number,
	company:string,
	domainMp:string,
	data:string,
	logo?:string
}>('admin/api/authorization/code', {
	data,
	custom: {
		auth: false,
	}
}
)
// #endif
// #ifdef PRIVATE
// 判断店铺是否开启了私域
export const getStoreSphere = (data: { storeId: string }) => api.get<ResponseData<number>>('merchant/customer/store/has/private/sphere',
	{
		data,
		custom: {
			auth: false,
		}
	}
)
// #endif
export type AppInitInfo = {
	code: number
	msg:string
	globalBg: SkinKey
	pages:[TabbarPageItem,TabbarPageItem,TabbarPageItem]
	start:{
		layout:string
	}
	isRefund:'true'|'false',
	bottomMenus:{
		cssDefault?:string,
		cssSelect?:string,
		layout:string,
		cssBg?:string
		cssClass:number
	}
}
// 初始化信息,包含装修的数据
export const getInitInfo = (data: { templateId?: string }) =>
	api.get<AppInitInfo>('system/api/config/init', {
		data,
		custom: {
			auth: false
		}
	}
)

// 获取地图服务的key
export const getMapKey = () =>
	api.get<ResponseData<{
		keyType:"1"|"2",
		key:string[]
	}>>('system/api/basics/keyMap',
		{
			custom: {
				auth: false
			}
		})

export interface LogisticsItem  {
	name:string,
	id:number
}

// 物流公司列表
export const getLogisticsList = () =>
	api.get<ResponseData<LogisticsItem[]>>(`system/api/basics/list`,
		{
			custom: {
				auth: false
			}
		}
	)

// 获取app版本
export const getAppVersion = () =>
	api.get<ResponseData<{
		appVersionMsg: string,
		appVersion: string,
		appIosUrl: string,
		appAndroidUrl: string,
		hotUpdateUrl: string
	}>>('system/api/basics/app/version/info',
		{
			custom: {
				auth: false
			}
		}
	)

export type addressItem = {
	id: number
	level: number
	name: string,
	pid: number
}
// 省级列表
export const getProvinceList = (data: { countryCode: string }) =>
	api.get<ResponseData<addressItem[]>>('system/api/address/province',
		{
			data,
			custom: {
				auth: false
			}
		})
// 市区级列表
export const getProvinceChildList = (id: number) =>
	api.get<ResponseData<addressItem[]>>(`system/api/address/tree/${id}`,
		{
			custom: {
				auth: false
			}
		})

export type DictsItem = {
	dictLabel: string,
	dictValue: string
	cssClass:string
}
// 字典 
export const getDicts = (type: string) =>
	api.get<ResponseData<DictsItem[]>>(`system/dict/data/type/${type}`);
	
export type SystemNoticeItem = {
	noticeId: number,
	noticeTitle:string
}
// 公告列表
export const getNoticeList = () =>
	api.get<ResponseData<SystemNoticeItem[],true>>('system/api/notice/list', {
		custom: {
			auth: false
		}
	}
	)
	
	// 获取可以切换的语言模版
	export const getLangList = () =>
		api.get(`system/api/page/tmplate/lang`);

	// 获取提现方式
	export const getCashConfig = () => api.get('system/cash/setting/config')